﻿using UnityEngine;
using System.Collections;
using UnityEditor;


public class  MyDisplay:EditorWindow{
	enum DisplayMode{
		InputText,
	}
	DisplayMode mode;
	string message = "";
	string ok = "";
	string cancel = "";

	string value1 = "";
	System.Action<string> onsumbint;
	public static MyDisplay Init(){
		return GetWindow<MyDisplay> ();
	}


	public static void InputTextsss(EditorWindow caller,string _message,string _ok,string _cancel,System.Action<string> _onsubmit){
		MyDisplay window = Init ();
		window.mode = DisplayMode.InputText;
		window.message = _message;
		window.ok = _ok;
		window.cancel = _cancel;
		window.onsumbint = _onsubmit;
		window.SetScale (300,100,caller.position);
	}

	public void SetScale (float x,float y,Rect caller){
		Vector2 scale = new Vector2 (x, y);
		Vector3 mouseposition = Vector3.zero;
		try{
			mouseposition = Event.current.mousePosition;
		}catch{
		}
		mouseposition.x += caller.position.x;
		mouseposition.y += caller.position.y;
		this.position = new Rect(mouseposition.x,mouseposition.y,x,y);
		this.maxSize = scale;
		this.minSize = scale;
	}

	void OnGUI(){
		switch (mode) {
		case DisplayMode.InputText:
			DrawInputText ();
			break;
		}
	}

	void DrawInputText(){
		GUILayout.Label (message);
		value1 = GUILayout.TextField (value1);
		EditorGUILayout.Space ();
		GUILayout.BeginHorizontal ();
		EditorGUILayout.Space ();
		EditorGUILayout.Space ();
		if (GUILayout.Button (ok,GUILayout.Width(40))) {
			onsumbint (value1);
			Close ();
		}
		if (GUILayout.Button (cancel,GUILayout.Width(40))) {
			Close ();
		}
		GUILayout.EndHorizontal ();
	}
}


public class PMConst{
	public static string PathModule = Application.dataPath+"/Script/Module/";
	public static string PathScene = Application.dataPath + "/Scene/";
	public static string PathPrefab = Application.dataPath+"/Resources/ViewUI/";
	public static string PMPath = Application.dataPath+"/NodeCanvas/Editor/PanelMaker/";
	public static string PMTemplate = Application.dataPath+"/NodeCanvas/Editor/PanelMaker/Template";
}

public enum CompilingMode{
	None,
	Module,
	View,
}